Skip to content

Handle MSI reboot-required exit codes as success in JdkInstaller#289

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/sub-pr-274
Draft

Handle MSI reboot-required exit codes as success in JdkInstaller#289
Copilot wants to merge 5 commits intomainfrom
copilot/sub-pr-274

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

msiexec returns non-zero codes 3010 and 1641 to indicate successful installation with a pending reboot — previously these were incorrectly treated as failures and threw an exception.

Changes

  • JdkInstaller.RunPlatformInstaller: detect Windows MSI reboot-required exit codes before the failure check
    • Exit codes 3010 (success, reboot required) and 1641 (success, restart initiated) are treated as success on Windows
    • A TraceLevel.Warning is logged when a reboot is needed
    • Non-zero codes that are not reboot signals still throw InvalidOperationException
var rebootRequired = OS.IsWindows && (exitCode == 3010 || exitCode == 1641);

if (exitCode != 0 && !rebootRequired) {
    var errorOutput = stderr.ToString ();
    logger (TraceLevel.Error, $"Installer failed (exit code {exitCode}): {errorOutput}");
    throw new InvalidOperationException ($"Platform installer failed with exit code {exitCode}: {errorOutput}");
}

if (rebootRequired) {
    logger (TraceLevel.Warning, $"Installer completed successfully but a reboot is required (exit code {exitCode}).");
}

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

rmarinho and others added 4 commits February 25, 2026 18:56
Implements JdkInstaller class for automated JDK installation:

- JDK discovery via Microsoft OpenJDK release API (supports JDK 21)
- Platform-aware download (Windows .zip/.msi, macOS .tar.gz/.pkg, Linux .tar.gz)
- SHA-256 checksum verification with Zip Slip protection
- Elevated install mode: uses native installers (.msi/.pkg) when running as admin/root
- Non-elevated mode: extracts archives to user-writable paths
- Atomic extraction with rollback on failure
- Cancellation support throughout the pipeline
- Progress reporting via IProgress<JdkInstallProgress>

Models organized in Models/Jdk/ folder:
- JdkVersionInfo, JdkReleaseInfo, JdkPlatformAsset
- JdkInstallProgress (record type for progress reporting)

Includes comprehensive tests for discovery, download, extraction, and error handling.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- IsTargetPathWritable: test nearest existing ancestor instead of creating target dir
- InstallWithPlatformInstallerAsync: fetch checksum before download
- IsElevatedUnix: guard geteuid P/Invoke with OperatingSystem.IsWindows() check
- Add SetLastError=true to geteuid DllImport

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- GetArchitectureName: explicitly handle X64, throw for unsupported archs
- IsTargetPathWritable: add directory boundary check (prevents false match on 'Program FilesX')
- Modernize catch filter to use 'is not' pattern
- Extract IsUnderDirectory helper

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: rmarinho <1235097+rmarinho@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix feedback on JDK installation support PR Handle MSI reboot-required exit codes as success in JdkInstaller Feb 25, 2026
Base automatically changed from feature/jdk-installer to main February 26, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants